package com.demo;

import androidx.exifinterface.media.ExifInterface;

public class JMUtil {
    public static String b(String str, String str2) {
        byte[] bArr = null;
        if (str == null || str2 == null) {
            return null;
        }
        int length = str.length() / 2;
        byte[] bArr2 = new byte[length];
        byte[] bytes = str.getBytes();
        for (int i = 0; i < length; i++) {
            int i2 = i * 2;
            byte b = bytes[i2];
            byte b2 = bytes[i2 + 1];
            StringBuilder p = b2.p("0x");
            p.append(new String(new byte[]{b}));
            StringBuilder p2 = b2.p("0x");
            p2.append(new String(new byte[]{b2}));
            bArr2[i] = (byte) (((char) Byte.decode(p2.toString()).byteValue()) ^ ((char) (((char) Byte.decode(p.toString()).byteValue()) << 4)));
        }
        byte[] bytes2 = str2.getBytes();
        byte[] bArr3 = new byte[256];
        for (int i3 = 0; i3 < 256; i3++) {
            bArr3[i3] = (byte) i3;
        }
        if (bytes2 != null && bytes2.length != 0) {
            int i4 = 0;
            int i5 = 0;
            for (int i6 = 0; i6 < 256; i6++) {
                i5 = ((bytes2[i4] & 0xff) + (bArr3[i6] & 0xff) + i5) & 255;
                byte b3 = bArr3[i6];
                bArr3[i6] = bArr3[i5];
                bArr3[i5] = b3;
                i4 = (i4 + 1) % bytes2.length;
            }
            bArr = bArr3;
        }
        byte[] bArr4 = new byte[length];
        int i7 = 0;
        int i8 = 0;
        for (int i9 = 0; i9 < length; i9++) {
            i7 = (i7 + 1) & 255;
            i8 = ((bArr[i7] & 0xff) + i8) & 255;
            byte b4 = bArr[i7];
            bArr[i7] = bArr[i8];
            bArr[i8] = b4;
            bArr4[i9] = (byte) (bArr[((bArr[i7] & 0xff) + (bArr[i8] & 0xff)) & 255] ^ bArr2[i9]);
        }
        return new String(bArr4);
    }

}
